<?php include template('header','admin');?>
	<body>
		<div class="fixed-nav layout">
			<ul>
				<li class="first">商户管理<a id="addHome" title="添加到首页快捷菜单">[+]</a></li>
				<li class="spacer-gray"></li>
				<li><a class="labelbox" data-id="1" href="<?php echo url('index',array('label' => 1))?>">全部商家</a></li>
				<li><a class="labelbox" data-id="2" href="<?php echo url('index',array('label' => 2))?>">正常商家</a></li>
				<li><a class="labelbox" data-id="3" href="<?php echo url('index',array('label' => 3))?>">锁定商家</a></li>
				<li><a class="labelbox" data-id="4" href="<?php echo url('index',array('label' => 4))?>">回收站</a></li>
				<!--li><a href="<?php echo url('account')?>">商户账号</a></li-->
			</ul>
			<div class="hr-gray"></div>
		</div>
		<div class="content padding-big have-fixed-nav">
			<div class="tips margin-tb">
				<div class="tips-info border">
					<h6>温馨提示</h6>
					<a id="show-tip" data-open="true" href="javascript:;">关闭操作提示</a>
				</div>
				<div class="tips-txt padding-small-top layout">
        			<p>- 通过商家管理，你可以进行查看、编辑商家资料以及锁定商家等操作</p>
        			<p>- 你可以根据条件搜索商家，输入商家名称、公司名称、推荐人、企业负责联系人等查找，然后选择相应的操作</p>
				</div>
			</div>
			<div class="hr-gray"></div>
			<div class="goods-list-search margin-top clearfix" >
			 <form action="<?php echo __APP__?>" method="get">
			 <input type="hidden" name="m" value="supplier">
			 <input type="hidden" name="c" value="admin">
			 <input type="hidden" name="a" value="index">
			 <input type="hidden" name="label" value="<?php echo $_GET['label'] ? $_GET['label'] : 1?>">
    		    <div class="form-group form-layout-rank border-none">
    				<span class="label">搜索</span>
    				<div class="box ">
    					<div class="field">
    						<input class="input" type="text" name="keyword" value="<?php echo $_GET['keyword']?>" data-reset="false" placeholder="输入商家名称/公司名/推荐名/联系人" tabindex="0">
    					</div>
    				</div>
    			</div>
                <input class="button bg-sub fl" type="submit" value="查询" />
            </div>
			</form>
			<div class="table-work border margin-tb">
				<div class="border border-white tw-wrap">
					<a href="<?php echo url('add')?>"><i class="ico_add"></i>添加</a>
					<div class="spacer-gray"></div>
                    <!--
        			<a data-message="是否锁定此商户，账号将不可使用？" href="<?php echo url('togglelock',array('islock'=>1))?>" data-ajax='ids'><i class="ico_lock"></i>锁定</a>
        			<div class="spacer-gray"></div>
        			<a data-message="是否解锁此商户？" href="<?php echo url('togglelock',array('islock'=>0))?>" data-ajax='ids'><i class="ico_unlock"></i>解锁</a>
        			<div class="spacer-gray"></div>
                    -->
				</div>
			</div>
			<div class="table resize-table check-table paging-table border clearfix">
				<div class="tr border-none">
					<div class="th check-option" data-resize="false">
						<input id="check-all" type="checkbox" />
					</div>
					<div class="th" data-width="15"><span class="td-con">商户名称 (简称)</span></div>
					<div class="th" data-width="30"><span class="td-con">公司名称</span></div>
					<div class="th" data-width="10"><span class="td-con">类别</span></div>
					<div class="th" data-width="10"><span class="td-con">推荐人</span></div>
					<div class="th" data-width="15"><span class="td-con">添加时间</span></div>
                    <div class="th" data-width="5"><span class="td-con">状态</span></div>
					<div class="th" data-width="15"><span class="td-con">操作</span></div>
				</div>
                <?php if(count($supplier) == 0){?>
                    <div class="tr rowspan-center">(^_^.) 当前条件，没有商家数据！</div>
                <?php }?>
                
				<?php foreach($supplier as $k=>$v):?>
					<div class="tr">
					<div class="td check-option"><input type="checkbox" name="id" value="<?php echo $v['id']?>" /></div>
					<div class="td">
						<div class="td-con">
							<div class="double-click">
								<a class="double-click-button margin-none padding-none" title="" href="javascript:;"></a>
								<input class="input double-click-edit text-ellipsis" data-id='<?php echo $v['id']?>' type="text" value="<?php echo $v['supplier_name']?>" />
							</div>
						</div>
					</div>
					<div class="td">
						<span class="td-con text-left">
                            <?php echo $v['company']?>
                        </span>
					</div>
					<div class="td">
						<span class="td-con"><?php echo $v['group_title']?></span>
					</div>
					<div class="td">
						<span class="td-con"><?php echo $v['recommender']?></span>
					</div>
					<div class="td">
						<span class="td-con"><?php echo $v['updata_time']?></span>
					</div>
					<div class="td">
						<span class="td-con">
                            <?php if ($v['status'] == 0){?> 
                            <i class="ico_up_rack" title="正常"></i>
                            <?php }else{ ?>
                            <i class="ico_down_rack" title="商户已锁定"></i>
                            <?php }?>
						</span>
					</div>      
					<div class="td">
						<span class="td-con"><span class="td-con"><a href="<?php echo url('edit',array('id'=>$v['id']))?>">编辑</a>&nbsp;&nbsp;&nbsp;
                        <?php if($_GET['label'] != 4){?>
						<a data-confirm="是否确定删除？" href="<?php echo url('ajax_del',array('id'=>$v['id'],'formhash'=>FORMHASH))?>">删除</a>
                        <?php }else{?>
                        <a data-confirm="是否确认恢复？" href="<?php echo url('ajax_recover',array('id[]'=>$v['id']))?>">恢复</a>
                        <?php }?>
						</span></span>
					</div>
				</div>
				<?php endforeach;?>
				
				<div class="paging padding-tb body-bg clearfix">
					<ul class="fr">
						<?php echo $pages?>
					</ul>
					<div class="clear"></div>
				</div>
			</div>
		</div>
		<script>
			var formhash='<?php echo FORMHASH?>';
			var del_url = "<?php echo url('del',array('formhash'=>FORMHASH))?>";
			var save_title_url = "<?php echo url('ajax_save_name')?>"
			var label = "<?php echo $_GET['label']?$_GET['label']:1?>";
			$(window).load(function(){
				$(".table").resizableColumns();
				$(".table").fixedPaging();
				$('.table .tr:last-child').addClass("border-none");
				//启用与关闭
				$(".table .ico_up_rack").bind('click',function(){
					if(!$(this).hasClass("cancel")){
						$(this).addClass("cancel");
						$(this).attr("title","点击显示");
					}else{
						$(this).removeClass("cancel");
						$(this).attr("title","点击关闭");
					}
				});
			})
			$(function(){
    			if(label){
    				$.each($('.labelbox'),function(i,item){
    					if($(item).attr('data-id') == label){
    						$(item).addClass('current');
    					}
    				})
    			}             
             
				//双击编辑
				$('.double-click-edit').on('blur',function(){
					$.post(save_title_url,{id:$(this).attr('data-id'),supplier_name:""+$(this).val()+"",formhash:""+formhash+""},function(data){
					})
				})
			})
		</script>
	</body>
</html>